<?php
	require_once($_SERVER["DOCUMENT_ROOT"]."/global.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/modules/security_mod.php");
	require_once($_SERVER["DOCUMENT_ROOT"]."/modules/channel_mod.php");

	SecurityMod::login();

	$level = $_SESSION["account"]->getLevel();
        $chatLevel = $_SESSION["account"]->getChatLevel();
	if ($level != "Admin" && $chatLevel != 3)
		SecurityMod::logout();

        $pid = v($_REQUEST, "pid");
        $userChannels = $_POST['userChannels'];
        if($userChannels){
            ChannelMod::updateUserChannels($pid, $userChannels);
        }
        
        header('location: accounts.php');
?>